package com.github.captcha.common.uitl;

import com.github.captcha.common.constant.CaptchaTypeConstant;

import java.util.stream.Stream;

/**
 * @Author: haichuan.lu
 * @date 2023/02/23 17:14
 * @Description 工具类
 */
public class CaptchaUtils {

    /**
     * 是否是滑动验证码
     *
     * @param type 类型
     * @return boolean
     */
    public static boolean isSliderCaptcha(String type) {
        return Stream.of(CaptchaTypeConstant.SLIDER, CaptchaTypeConstant.ROTATE, CaptchaTypeConstant.CONCAT)
                .anyMatch(s -> s.equals(type));
    }

    /**
     * 是否是点击验证码
     *
     * @param type type
     * @return boolean
     */
    public static boolean isClickCaptcha(String type) {
        return Stream.of(CaptchaTypeConstant.WORD_IMAGE_CLICK, CaptchaTypeConstant.IMAGE_CLICK)
                .anyMatch(s -> s.equals(type));
    }
}
